/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.lczyfz.wisdom.modules.platform.vueweb;

import com.lczyfz.wisdom.common.utils.ServerResponse;
import com.lczyfz.wisdom.modules.platform.entity.Address;
import com.lczyfz.wisdom.modules.platform.entity.SysRegion;
import com.lczyfz.wisdom.modules.platform.service.AddressService;
import com.lczyfz.wisdom.modules.platform.service.SysRegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * addressController
 * @author zkh
 * @version 2019-09-26
 */
@Api(value = "address",description = "地址信息接口管理")
@RestController
@RequestMapping(value = "${apiPath}/address/pAddress")
public class VueAddressController{


	@Autowired
	private AddressService addressService;
	@Autowired
	private SysRegionService sysRegionService;


	@ApiOperation(value = "获取用户所有的收货地址",notes = "获取用户所有的收货地址")
	@RequestMapping(value = "getInfoByUserId",method = RequestMethod.GET)
	public ServerResponse getInfoByUserId(@RequestParam("userId")String userId) {
		return addressService.getInfoByUserId(userId);
	}

	@ApiOperation(value = "保存或修改用户地址",notes = "保存用户地址")
	@RequestMapping(value = "saveAddress",method = RequestMethod.POST)
	public ServerResponse saveAddress(@RequestBody Address address) {
		return addressService.saveAddress(address);
	}

	@ApiOperation(value = "删除用户收货地址",notes = "删除用户收货地址")
	@RequestMapping(value = "deleteAddress",method = RequestMethod.DELETE)
	public ServerResponse deleteAddress(@RequestParam("id")String id) {
		return addressService.deleteAddress(id);
	}

	@ApiOperation(value = "设置默认地址",notes = "设置默认地址")
	@RequestMapping(value = "updateIsDefault",method = RequestMethod.GET)
	public ServerResponse updateIsDefault(@RequestParam("id")String id,@RequestParam("userId")String userId) {
		return addressService.updateIsDefault(id,userId);
	}

	@ApiOperation(value = "获取省市区地址树形菜单",notes = "获取省市区地址树形菜单")
	@RequestMapping(value = "getSysRegionInfo",method = RequestMethod.GET)
	public ServerResponse<SysRegion> getSysRegionInfo() {
		return sysRegionService.getAll();
	}


}